package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizTrainIcon;
import com.ruoyi.biz.service.IBizTrainIconService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 火车图标Controller
 * 
 * @author cc
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/system/train_icon")
public class BizTrainIconController extends BaseController
{
    @Autowired
    private IBizTrainIconService bizTrainIconService;

    /**
     * 查询火车图标列表
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTrainIcon bizTrainIcon)
    {
        startPage();
        List<BizTrainIcon> list = bizTrainIconService.selectBizTrainIconList(bizTrainIcon);
        return getDataTable(list);
    }

    /**
     * 导出火车图标列表
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:export')")
    @Log(title = "火车图标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizTrainIcon bizTrainIcon)
    {
        List<BizTrainIcon> list = bizTrainIconService.selectBizTrainIconList(bizTrainIcon);
        ExcelUtil<BizTrainIcon> util = new ExcelUtil<BizTrainIcon>(BizTrainIcon.class);
        util.exportExcel(response, list, "火车图标数据");
    }

    /**
     * 获取火车图标详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizTrainIconService.selectBizTrainIconById(id));
    }

    /**
     * 新增火车图标
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:add')")
    @Log(title = "火车图标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTrainIcon bizTrainIcon)
    {
        return toAjax(bizTrainIconService.insertBizTrainIcon(bizTrainIcon));
    }

    /**
     * 修改火车图标
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:edit')")
    @Log(title = "火车图标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTrainIcon bizTrainIcon)
    {
        return toAjax(bizTrainIconService.updateBizTrainIcon(bizTrainIcon));
    }

    /**
     * 删除火车图标
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:remove')")
    @Log(title = "火车图标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizTrainIconService.deleteBizTrainIconByIds(ids));
    }

    /**
     * 根据用户获取火车图标详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:train_icon:query')")
    @GetMapping(value = "/getAll")
    public AjaxResult getAll()
    {
        return success(bizTrainIconService.getAllByUser(getLoginUser()));
    }
}
